package com.css.zfzx.sjcj.modules.hddcB1GeologySvyProjectTable.repository;

import com.css.zfzx.sjcj.modules.hddcB1GeologySvyProjectTable.repository.entity.HddcB1GeologysvyprojecttableEntity;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author zyb
 * @date 2020-11-30
 */
public interface HddcB1GeologysvyprojecttableRepository extends JpaRepository<HddcB1GeologysvyprojecttableEntity, String> {
    @Modifying
    @Query(nativeQuery = true,value = "update hddc_b1_geologysvyprojecttable set qualityinspection_status=:qualityinspection_status ,extends1=:extend1 where workregionid=:workregionid")
    void updateStatus(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend1") String extend1,@Param("workregionid")String workregionid);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_b1_geologysvyprojecttable set qualityinspection_status=:qualityinspection_status ,extends2=:extend2 where targetregionid=:targetregionid")
    void update2Status(@Param("qualityinspection_status") String qualityinspection_status,@Param("extend2") String extend2,@Param("targetregionid")String targetregionid);

    @Query(nativeQuery = true,value="select t.* from hddc_b1_geologysvyprojecttable  t where t.id=?1 and t.is_valid=1")
    HddcB1GeologysvyprojecttableEntity findbyId(String id);

    @Modifying
    @Query(nativeQuery = true,value = "update hddc_b1_geologysvyprojecttable set qualityinspection_status=:s ,extends3=:str where targetregionid=:id")
    void update3Status(String s, String str, String id);

    @Query(nativeQuery=true,value = "select * from hddc_b1_geologysvyprojecttable where is_valid=1 and " +
            "(qualityinspection_status!=3 or qualityinspection_status is null)")
    List<HddcB1GeologysvyprojecttableEntity> findByAll();

    HddcB1GeologysvyprojecttableEntity findByUuidAndIsValid(String id, String isValid);
}
